import Vue from 'vue';
import Vuex from 'vuex';
import Axios from 'axios';

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    shoppList: [],
    cartList: []
  },
  mutations: {
    addShopp(state, data) {
      // console.log(23232323);
      // console.log(this);
      // console.log(data);
      state.shoppList = data;
      // console.log(state.shoppList);
    },
    addCart(state, data) {
      state.cartList.push(data);
    }
  },
  actions: {
    getShoppList() {
      return Axios.get('./shoppList.json').then(data => {
        console.log(data.data);
        this.commit('addShopp', data.data);
        console.log(121212);
        // console.log(this);
      });
    }
  },
  modules: {}
});
